<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>grid 布局</title>
    <style>
    .container {
        display: grid;
        /* grid-template-columns: 100px 100px 100px; */
        /* grid-template-columns: 1fr 1fr 1fr; */
        /* grid-template-rows: 50px 50px; */
        /* grid-template-columns: repeat(3, 100px); */
        /* grid-template-columns: repeat(auto-fit, 100px); */
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        grid-template-rows: repeat(2, 50px);
    }
    .container > div > img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    .container div:nth-child(1){
        background-color:aqua;
    }
    .container div:nth-child(2){
        background-color:beige;
    }
    .container div:nth-child(3){
        background-color:lightcyan;
    }
    .container div:nth-child(4){
        background-color:crimson;
    }
    .container div:nth-child(5){
        background-color:rgb(185, 152, 170);
    }
    .container div:nth-child(6){
        background-color:rgb(109, 189, 69);
    }
    </style>
</head>
<body>
    <div class="container">
        <div>
            <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202007%2F08%2F20200708131208_UcKSv.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654786456&t=5730a3e8cf04f5fd1f96cdb86cd02867"/>
        </div>
        <div>
            <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202007%2F08%2F20200708131208_UcKSv.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654786456&t=5730a3e8cf04f5fd1f96cdb86cd02867"/>
        </div>
        <div>
            <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202007%2F08%2F20200708131208_UcKSv.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654786456&t=5730a3e8cf04f5fd1f96cdb86cd02867"/>
        </div>
        <div>
            <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202007%2F08%2F20200708131208_UcKSv.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654786456&t=5730a3e8cf04f5fd1f96cdb86cd02867"/>
        </div>
        <div>
            <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202007%2F08%2F20200708131208_UcKSv.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654786456&t=5730a3e8cf04f5fd1f96cdb86cd02867"/>
        </div>
        <div>
            <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202007%2F08%2F20200708131208_UcKSv.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654786456&t=5730a3e8cf04f5fd1f96cdb86cd02867"/>
        </div>
    </div>
</body>
</html>